package com.github.MrWub.key.event;

import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

public class KeyPressEvent extends Event implements Cancellable{
    private static final HandlerList handlers = new HandlerList();
    private Player player;
    private int keyNo;
    private boolean cancelled = false;
    private boolean did = false;
    /**
     * 是否有监听器先一步将其拦截并处理,
     * 如果你需要更早的监听这个事件,请提高你的优先级,
     * 如果你只是需要拦截这一事件,则监听PreKeyPressEvent.他会在这之前唤起.
     * @return boolean.
     */
    public boolean isDid() {
		return did;
	}
    
	public void setDid(boolean did) {
		this.did = did;
	}

	public KeyPressEvent(final Player player,int keyNo) {
        this.player = player;
        this.keyNo = keyNo;
    }

    public Player getPlayer() {
        return player;
    }
    
    public int getKeyNo() {
    	return keyNo;
    }
    
    public HandlerList getHandlers() {
        return handlers;
    }
    
    
    public static HandlerList getHandlerList() {
        return handlers;
    }
    
	@Override
	public boolean isCancelled() {
		return this.cancelled;
	}

	@Override
	public void setCancelled(boolean is) {
		this.cancelled = is;
	}
}